//
//  BTButton.m
//  halfSweat
//
//  Created by 甘伟杰 on 16/5/12.
//  Copyright © 2016年 ganweijie. All rights reserved.
//

#import "BTButton.h"

@implementation BTButton

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.titleLabel setFont:[UIFont systemFontOfSize:10]];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];

    CGFloat imageH = self.frame.size.height * 0.7;
    CGFloat imageW = imageH;
    CGFloat imageX = (self.frame.size.width - imageW) * 0.5;
    CGFloat imageY = 0;
    self.imageView.frame = CGRectMake(imageX, imageY, imageW, imageH);
    
    CGFloat titleW = self.frame.size.width;
    CGFloat titleH = self.frame.size.height - imageH;
    CGFloat titleX = 0;
    CGFloat titleY = self.frame.size.height - titleH;
    self.titleLabel.frame = CGRectMake(titleX, titleY, titleW, titleH);
}

@end
